{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "collapsed_sections": [
        "zkufh760uvF3"
      ]
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "zkufh760uvF3"
      },
      "source": [
        "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
        "\n",
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/Training/binary_text_classification/NLU_training_sentiment_classifier_demo_IMDB.ipynb)\n",
        "\n",
        "\n",
        "# Training a Sentiment Analysis Classifier with NLU\n",
        "## 2 class IMDB Movie sentiment classifier training\n",
        "With the [SentimentDL model](https://nlp.johnsnowlabs.com/docs/en/annotators#sentimentdl-multi-class-sentiment-analysis-annotator) from Spark NLP you can achieve State Of the Art results on any multi class text classification problem\n",
        "\n",
        "This notebook showcases the following features :\n",
        "\n",
        "- How to train the deep learning classifier\n",
        "- How to store a pipeline to disk\n",
        "- How to load the pipeline from disk (Enables NLU offline mode)\n",
        "\n",
        "You can achieve these results or even better on this dataset with training data:\n",
        "\n",
        "\n",
        "<br>\n",
        "\n",
        "\n",
        "![image.png]()\n",
        "\n",
        "\n",
        "\n",
        "You  can achieve these results or even better on this dataset with test  data:\n",
        "\n",
        "\n",
        "<br>\n",
        "\n",
        "\n",
        "![image.png]()\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "dur2drhW5Rvi"
      },
      "source": [
        "# 1. Install Java 8 and NLU"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "hFGnBCHavltY"
      },
      "source": [
        "!pip install -q johnsnowlabs"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "f4KkTfnR5Ugg"
      },
      "source": [
        "# 2. Download IMDB dataset\n",
        "https://www.kaggle.com/lakshmi25npathi/imdb-dataset-of-50k-movie-reviews\n",
        "\n",
        "IMDB dataset having 50K movie reviews for natural language processing or Text analytics.\n",
        "This is a dataset for binary sentiment classification containing substantially more data than previous benchmark datasets. We provide a set of 25,000 highly polar movie reviews for training and 25,000 for testing. So, predict the number of positive and negative reviews using either classification or deep learning algorithms.\n",
        "For more dataset information, please go through the following link,\n",
        "http://ai.stanford.edu/~amaas/data/sentiment/"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "OrVb5ZMvvrQD"
      },
      "source": [
        "! wget https://s3.amazonaws.com/auxdata.johnsnowlabs.com/public/resources/en/classifier-dl/IMDB/IMDB-Dataset.csv\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 424
        },
        "id": "y4xSRWIhwT28",
        "outputId": "dd2c7a9f-1f4c-4c30-98ee-9cf666d4d44b"
      },
      "source": [
        "import pandas as pd\n",
        "from johnsnowlabs import nlp\n",
        "train_path = '/content/IMDB-Dataset.csv'\n",
        "\n",
        "train_df = pd.read_csv(train_path)\n",
        "# the text data to use for classification should be in a column named 'text'\n",
        "# the label column must have name 'y' name be of type str\n",
        "columns=['text','y']\n",
        "train_df = train_df[columns]\n",
        "from sklearn.model_selection import train_test_split\n",
        "\n",
        "train_df, test_df = train_test_split(train_df, test_size=0.2)\n",
        "train_df"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                                    text         y\n",
              "11147  I have not seen and heard the original version...  negative\n",
              "5176   Ghost Story has an interesting feminist reveng...  negative\n",
              "23853  Christ. A sequel to one of the most cloying fi...  negative\n",
              "12990  Mendez and Marichal have provided us with a se...  positive\n",
              "28039  \"Bend It Like Beckham\" is a film that got very...  positive\n",
              "...                                                  ...       ...\n",
              "30425  This movie is a lot better than the asylums ve...  positive\n",
              "6508   I concur with everyone above who said anything...  negative\n",
              "2432   The \"Wrinkle in Time\" book series is my favori...  negative\n",
              "12347  Clint Eastwood scores big in this thriller fro...  positive\n",
              "3332   This is the one major problem with this film, ...  negative\n",
              "\n",
              "[39999 rows x 2 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-c58211d5-8340-40a5-b7ce-1b7d6b0ccc90\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>text</th>\n",
              "      <th>y</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>11147</th>\n",
              "      <td>I have not seen and heard the original version...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5176</th>\n",
              "      <td>Ghost Story has an interesting feminist reveng...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>23853</th>\n",
              "      <td>Christ. A sequel to one of the most cloying fi...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12990</th>\n",
              "      <td>Mendez and Marichal have provided us with a se...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>28039</th>\n",
              "      <td>\"Bend It Like Beckham\" is a film that got very...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>30425</th>\n",
              "      <td>This movie is a lot better than the asylums ve...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6508</th>\n",
              "      <td>I concur with everyone above who said anything...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2432</th>\n",
              "      <td>The \"Wrinkle in Time\" book series is my favori...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12347</th>\n",
              "      <td>Clint Eastwood scores big in this thriller fro...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3332</th>\n",
              "      <td>This is the one major problem with this film, ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>39999 rows × 2 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-c58211d5-8340-40a5-b7ce-1b7d6b0ccc90')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-c58211d5-8340-40a5-b7ce-1b7d6b0ccc90 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-c58211d5-8340-40a5-b7ce-1b7d6b0ccc90');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-244b9cba-f283-4bc4-924b-6ebc00c9a59a\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-244b9cba-f283-4bc4-924b-6ebc00c9a59a')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-244b9cba-f283-4bc4-924b-6ebc00c9a59a button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 2
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0296Om2C5anY"
      },
      "source": [
        "# 3. Train Deep Learning Classifier using nlu.load('train.sentiment')\n",
        "\n",
        "You dataset label column should be named 'y' and the feature column with text data should be named 'text'"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "3ZIPkRkWftBG",
        "outputId": "a1d1177f-d728-4338-cb76-aff8f37c6a65"
      },
      "source": [
        "from johnsnowlabs import nlp\n",
        "from sklearn.metrics import classification_report\n",
        "\n",
        "# load a trainable pipeline by specifying the train. prefix  and fit it on a datset with label and text columns\n",
        "# by default the Universal Sentence Encoder (USE) Sentence embeddings are used for generation\n",
        "trainable_pipe = nlp.load('train.sentiment')\n",
        "fitted_pipe = trainable_pipe.fit(train_df.iloc[:50])\n",
        "\n",
        "# predict with the trainable pipeline on dataset and get predictions\n",
        "preds = fitted_pipe.predict(train_df.iloc[:50],output_level='document')\n",
        "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))\n",
        "\n",
        "preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "sent_small_bert_L2_128 download started this may take some time.\n",
            "Approximate size to download 16.1 MB\n",
            "[OK!]\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       0.00      0.00      0.00        23\n",
            "    positive       0.54      1.00      0.70        27\n",
            "\n",
            "    accuracy                           0.54        50\n",
            "   macro avg       0.27      0.50      0.35        50\n",
            "weighted avg       0.29      0.54      0.38        50\n",
            "\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                             document  \\\n",
              "0   This film has to be viewed in the right frame ...   \n",
              "1   This is just a long advertisement for the movi...   \n",
              "2   This movie was physically painful to sit throu...   \n",
              "3   This movie was one of a handful that actually ...   \n",
              "4   I was pleasantly pleased with the ending. I ju...   \n",
              "5   I would purchase this and \"Thirty Seconds Over...   \n",
              "6   In any number of films, you can find Nicholas ...   \n",
              "7   This film is quite boring. There are snippets ...   \n",
              "8   Let's start this review out on a positive note...   \n",
              "9   Payback is the game being played in this drama...   \n",
              "10  Anthony Quinn is a master at capturing our hea...   \n",
              "11  Someone, some day, should do a study of archit...   \n",
              "12  Thats My Bush is first of all a very entertain...   \n",
              "13  The Last American Virgin (1982) was one of the...   \n",
              "14  I experienced Nightbreed for the first time on...   \n",
              "15  When I checked out the review for this film af...   \n",
              "16  This movie is a very realistic view of a polic...   \n",
              "17  The fact that after 50 years, it is still a hi...   \n",
              "18  One of the great mysteries of life, suffered f...   \n",
              "19  This movie is the Latino Godfather. An unlikel...   \n",
              "20  This is one fine movie, I can watch it any tim...   \n",
              "21  I love Meatballs! Terrific characters and poig...   \n",
              "22  Clocking in at an interminable three hours and...   \n",
              "23  Sudden Impact is the 4th of the Dirty Harry fi...   \n",
              "24  In a genre by itself, this film has a limited ...   \n",
              "25  The One and only was a great film. I had just ...   \n",
              "26  If you are 10 years old and never seen a movie...   \n",
              "27  Even if it were remotely funny, this mouldy wa...   \n",
              "28  This is one of the best bond games i have ever...   \n",
              "29  The performances rate better than the rating I...   \n",
              "30  Chinese Ghost Story III is a totally superfluo...   \n",
              "31  Fred Williamson, one of the two or three top b...   \n",
              "32  Vince Lombardi High School has a new principal...   \n",
              "33  It's hard to comment on this movie. It's one o...   \n",
              "34  I commend pictures that try something differen...   \n",
              "35  It's not just that this is a bad movie; it's n...   \n",
              "36  In order to enjoy 'Fur - An imaginary portrait...   \n",
              "37  I became a fan of the TV series `Homicide: Lif...   \n",
              "38  A terminally dull mystery-thriller, which may ...   \n",
              "39  this movie, while it could be considered an al...   \n",
              "40  This is the \"Battlefield Earth\" of mini series...   \n",
              "41  DVD has become the equivalent of the old late ...   \n",
              "42  I saw this movie when I was very young living ...   \n",
              "43  This may not be a memorable classic, but it is...   \n",
              "44  This is a great film for pure entertainment, n...   \n",
              "45  When I saw this on TV I was nervous...whats if...   \n",
              "46  This film without doubt is one of the worst I ...   \n",
              "47  \"Challenge to be Free\" was one of the first fi...   \n",
              "48  I bought this movie a few days ago, and though...   \n",
              "49  This movie is not as good as all think. the ac...   \n",
              "\n",
              "                 sentence_embedding_small_bert_L2_128 sentiment  \\\n",
              "0   [-0.1513771265745163, 0.3099152743816376, -0.2...  positive   \n",
              "1   [-0.3328755795955658, 0.2796784043312073, 0.10...  positive   \n",
              "2   [-0.6589022278785706, 0.09297071397304535, 0.0...  positive   \n",
              "3   [-0.5372501015663147, 0.5361205339431763, -0.0...  positive   \n",
              "4   [-0.3981836140155792, 0.3446210026741028, -0.0...  positive   \n",
              "5   [-0.4655883014202118, 0.7156240940093994, -0.1...  positive   \n",
              "6   [-0.366023987531662, 0.2559768557548523, -0.03...  positive   \n",
              "7   [-0.4195595383644104, 0.37842151522636414, -0....  positive   \n",
              "8   [-0.5557488203048706, -0.04156230762600899, 0....  positive   \n",
              "9   [-0.48163551092147827, 0.21267670392990112, -0...  positive   \n",
              "10  [-0.710480809211731, 0.029913106933236122, -0....  positive   \n",
              "11  [-0.6811888813972473, -0.06688129156827927, -0...  positive   \n",
              "12  [-0.5853302478790283, 0.4730848968029022, 0.01...  positive   \n",
              "13  [-0.4013202488422394, 0.19056788086891174, -0....  positive   \n",
              "14  [-0.22270944714546204, 0.22281427681446075, 0....  positive   \n",
              "15  [-0.39890941977500916, 0.403655081987381, -0.0...  positive   \n",
              "16  [-0.5352460145950317, 0.13765230774879456, -0....  positive   \n",
              "17  [-0.2797639071941376, -0.11143724620342255, -0...  positive   \n",
              "18  [-0.5399389863014221, 0.385494589805603, -0.17...  positive   \n",
              "19  [-0.37433841824531555, 0.10099871456623077, 0....  positive   \n",
              "20  [-1.3702389001846313, 0.30410271883010864, -0....  positive   \n",
              "21  [-0.9990127086639404, 0.07002592086791992, -0....  positive   \n",
              "22  [-0.27705344557762146, -0.5027639865875244, 0....  positive   \n",
              "23  [-0.5442849397659302, 0.2992677688598633, -0.2...  positive   \n",
              "24  [-0.14087404310703278, 0.12531475722789764, -0...  positive   \n",
              "25  [-0.68660968542099, 0.14108557999134064, 0.091...  positive   \n",
              "26  [-0.6596466302871704, 0.1337697058916092, -0.1...  positive   \n",
              "27  [-0.6116098761558533, 0.49599868059158325, 0.0...  positive   \n",
              "28  [-0.03306262567639351, -0.01435087714344263, -...  positive   \n",
              "29  [-0.9807755947113037, 0.5014723539352417, -0.4...  positive   \n",
              "30  [0.17701220512390137, -0.3180699050426483, -0....  positive   \n",
              "31  [-0.3707915246486664, 0.044643059372901917, -0...  positive   \n",
              "32  [-0.49639755487442017, 0.48042890429496765, -0...  positive   \n",
              "33  [-0.3472699224948883, 0.6240038275718689, -0.2...  positive   \n",
              "34  [-0.3393455743789673, 0.5790384411811829, -0.1...  positive   \n",
              "35  [-0.3814673125743866, -0.26899996399879456, -0...  positive   \n",
              "36  [-0.03743020445108414, 0.3995753526687622, -0....  positive   \n",
              "37  [-0.4682881832122803, -0.018485404551029205, -...  positive   \n",
              "38  [-0.18775352835655212, 0.06152409315109253, -0...  positive   \n",
              "39  [-0.507961094379425, 0.4713260531425476, -0.16...  positive   \n",
              "40  [-0.4353094696998596, 0.027452869340777397, -0...  positive   \n",
              "41  [-0.1517794281244278, 0.2896312475204468, -0.2...  positive   \n",
              "42  [-0.14374561607837677, 0.10458363592624664, -0...  positive   \n",
              "43  [-0.6834889650344849, 0.5808060169219971, -0.2...  positive   \n",
              "44  [-0.5870745778083801, 0.007088684476912022, 0....  positive   \n",
              "45  [-0.8343449234962463, 0.2768908441066742, -0.5...  positive   \n",
              "46  [-0.48633041977882385, 0.6339375972747803, -0....  positive   \n",
              "47  [-0.30197039246559143, 0.4937012493610382, -0....  positive   \n",
              "48  [-0.6582587361335754, 0.1842564195394516, -0.2...  positive   \n",
              "49  [-0.33901163935661316, 0.04764261469244957, 0....  positive   \n",
              "\n",
              "   sentiment_confidence                                               text  \\\n",
              "0                   0.0  This film has to be viewed in the right frame ...   \n",
              "1                   0.0  This is just a long advertisement for the movi...   \n",
              "2                   0.0  This movie was physically painful to sit throu...   \n",
              "3                   0.0  This movie was one of a handful that actually ...   \n",
              "4                   0.0  I was pleasantly pleased with the ending. I ju...   \n",
              "5                   0.0  I would purchase this and \"Thirty Seconds Over...   \n",
              "6                   0.0  In any number of films, you can find Nicholas ...   \n",
              "7                   0.0  This film is quite boring. There are snippets ...   \n",
              "8                   0.0  Let's start this review out on a positive note...   \n",
              "9                   0.0  Payback is the game being played in this drama...   \n",
              "10                  0.0  Anthony Quinn is a master at capturing our hea...   \n",
              "11                  0.0  Someone, some day, should do a study of archit...   \n",
              "12                  0.0  Thats My Bush is first of all a very entertain...   \n",
              "13                  0.0  The Last American Virgin (1982) was one of the...   \n",
              "14                  0.0  I experienced Nightbreed for the first time on...   \n",
              "15                  0.0  When I checked out the review for this film af...   \n",
              "16                  0.0  This movie is a very realistic view of a polic...   \n",
              "17                  0.0  The fact that after 50 years, it is still a hi...   \n",
              "18                  0.0  One of the great mysteries of life, suffered f...   \n",
              "19                  0.0  This movie is the Latino Godfather. An unlikel...   \n",
              "20                  0.0  This is one fine movie, I can watch it any tim...   \n",
              "21                  0.0  I love Meatballs! Terrific characters and poig...   \n",
              "22                  0.0  Clocking in at an interminable three hours and...   \n",
              "23                  0.0  Sudden Impact is the 4th of the Dirty Harry fi...   \n",
              "24                  0.0  In a genre by itself, this film has a limited ...   \n",
              "25                  0.0  The One and only was a great film. I had just ...   \n",
              "26                  0.0  If you are 10 years old and never seen a movie...   \n",
              "27                  0.0  Even if it were remotely funny, this mouldy wa...   \n",
              "28                  0.0  This is one of the best bond games i have ever...   \n",
              "29                  0.0  The performances rate better than the rating I...   \n",
              "30                  0.0  Chinese Ghost Story III is a totally superfluo...   \n",
              "31                  0.0  Fred Williamson, one of the two or three top b...   \n",
              "32                  0.0  Vince Lombardi High School has a new principal...   \n",
              "33                  0.0  It's hard to comment on this movie. It's one o...   \n",
              "34                  0.0  I commend pictures that try something differen...   \n",
              "35                  0.0  It's not just that this is a bad movie; it's n...   \n",
              "36                  0.0  In order to enjoy 'Fur - An imaginary portrait...   \n",
              "37                  0.0  I became a fan of the TV series `Homicide: Lif...   \n",
              "38                  0.0  A terminally dull mystery-thriller, which may ...   \n",
              "39                  0.0  this movie, while it could be considered an al...   \n",
              "40                  0.0  This is the \"Battlefield Earth\" of mini series...   \n",
              "41                  0.0  DVD has become the equivalent of the old late ...   \n",
              "42                  0.0  I saw this movie when I was very young living ...   \n",
              "43                  0.0  This may not be a memorable classic, but it is...   \n",
              "44                  0.0  This is a great film for pure entertainment, n...   \n",
              "45                  0.0  When I saw this on TV I was nervous...whats if...   \n",
              "46                  0.0  This film without doubt is one of the worst I ...   \n",
              "47                  0.0  \"Challenge to be Free\" was one of the first fi...   \n",
              "48                  0.0  I bought this movie a few days ago, and though...   \n",
              "49                  0.0  This movie is not as good as all think. the ac...   \n",
              "\n",
              "           y  \n",
              "0   positive  \n",
              "1   negative  \n",
              "2   negative  \n",
              "3   negative  \n",
              "4   negative  \n",
              "5   positive  \n",
              "6   positive  \n",
              "7   negative  \n",
              "8   positive  \n",
              "9   negative  \n",
              "10  positive  \n",
              "11  negative  \n",
              "12  positive  \n",
              "13  positive  \n",
              "14  positive  \n",
              "15  negative  \n",
              "16  positive  \n",
              "17  positive  \n",
              "18  positive  \n",
              "19  positive  \n",
              "20  positive  \n",
              "21  positive  \n",
              "22  negative  \n",
              "23  positive  \n",
              "24  positive  \n",
              "25  positive  \n",
              "26  negative  \n",
              "27  negative  \n",
              "28  positive  \n",
              "29  negative  \n",
              "30  negative  \n",
              "31  negative  \n",
              "32  positive  \n",
              "33  negative  \n",
              "34  positive  \n",
              "35  negative  \n",
              "36  negative  \n",
              "37  positive  \n",
              "38  negative  \n",
              "39  negative  \n",
              "40  negative  \n",
              "41  negative  \n",
              "42  positive  \n",
              "43  positive  \n",
              "44  positive  \n",
              "45  positive  \n",
              "46  negative  \n",
              "47  positive  \n",
              "48  positive  \n",
              "49  negative  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-740b2ac8-3077-4293-8405-e98332304cb9\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>document</th>\n",
              "      <th>sentence_embedding_small_bert_L2_128</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "      <th>text</th>\n",
              "      <th>y</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>This film has to be viewed in the right frame ...</td>\n",
              "      <td>[-0.1513771265745163, 0.3099152743816376, -0.2...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This film has to be viewed in the right frame ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>This is just a long advertisement for the movi...</td>\n",
              "      <td>[-0.3328755795955658, 0.2796784043312073, 0.10...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This is just a long advertisement for the movi...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>This movie was physically painful to sit throu...</td>\n",
              "      <td>[-0.6589022278785706, 0.09297071397304535, 0.0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This movie was physically painful to sit throu...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>This movie was one of a handful that actually ...</td>\n",
              "      <td>[-0.5372501015663147, 0.5361205339431763, -0.0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This movie was one of a handful that actually ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>I was pleasantly pleased with the ending. I ju...</td>\n",
              "      <td>[-0.3981836140155792, 0.3446210026741028, -0.0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I was pleasantly pleased with the ending. I ju...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>I would purchase this and \"Thirty Seconds Over...</td>\n",
              "      <td>[-0.4655883014202118, 0.7156240940093994, -0.1...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I would purchase this and \"Thirty Seconds Over...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>In any number of films, you can find Nicholas ...</td>\n",
              "      <td>[-0.366023987531662, 0.2559768557548523, -0.03...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>In any number of films, you can find Nicholas ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>This film is quite boring. There are snippets ...</td>\n",
              "      <td>[-0.4195595383644104, 0.37842151522636414, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This film is quite boring. There are snippets ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>Let's start this review out on a positive note...</td>\n",
              "      <td>[-0.5557488203048706, -0.04156230762600899, 0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Let's start this review out on a positive note...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>Payback is the game being played in this drama...</td>\n",
              "      <td>[-0.48163551092147827, 0.21267670392990112, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Payback is the game being played in this drama...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>10</th>\n",
              "      <td>Anthony Quinn is a master at capturing our hea...</td>\n",
              "      <td>[-0.710480809211731, 0.029913106933236122, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Anthony Quinn is a master at capturing our hea...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>11</th>\n",
              "      <td>Someone, some day, should do a study of archit...</td>\n",
              "      <td>[-0.6811888813972473, -0.06688129156827927, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Someone, some day, should do a study of archit...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12</th>\n",
              "      <td>Thats My Bush is first of all a very entertain...</td>\n",
              "      <td>[-0.5853302478790283, 0.4730848968029022, 0.01...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Thats My Bush is first of all a very entertain...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>13</th>\n",
              "      <td>The Last American Virgin (1982) was one of the...</td>\n",
              "      <td>[-0.4013202488422394, 0.19056788086891174, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>The Last American Virgin (1982) was one of the...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>14</th>\n",
              "      <td>I experienced Nightbreed for the first time on...</td>\n",
              "      <td>[-0.22270944714546204, 0.22281427681446075, 0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I experienced Nightbreed for the first time on...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>15</th>\n",
              "      <td>When I checked out the review for this film af...</td>\n",
              "      <td>[-0.39890941977500916, 0.403655081987381, -0.0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>When I checked out the review for this film af...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>16</th>\n",
              "      <td>This movie is a very realistic view of a polic...</td>\n",
              "      <td>[-0.5352460145950317, 0.13765230774879456, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This movie is a very realistic view of a polic...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>17</th>\n",
              "      <td>The fact that after 50 years, it is still a hi...</td>\n",
              "      <td>[-0.2797639071941376, -0.11143724620342255, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>The fact that after 50 years, it is still a hi...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>18</th>\n",
              "      <td>One of the great mysteries of life, suffered f...</td>\n",
              "      <td>[-0.5399389863014221, 0.385494589805603, -0.17...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>One of the great mysteries of life, suffered f...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>19</th>\n",
              "      <td>This movie is the Latino Godfather. An unlikel...</td>\n",
              "      <td>[-0.37433841824531555, 0.10099871456623077, 0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This movie is the Latino Godfather. An unlikel...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>20</th>\n",
              "      <td>This is one fine movie, I can watch it any tim...</td>\n",
              "      <td>[-1.3702389001846313, 0.30410271883010864, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This is one fine movie, I can watch it any tim...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>21</th>\n",
              "      <td>I love Meatballs! Terrific characters and poig...</td>\n",
              "      <td>[-0.9990127086639404, 0.07002592086791992, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I love Meatballs! Terrific characters and poig...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>22</th>\n",
              "      <td>Clocking in at an interminable three hours and...</td>\n",
              "      <td>[-0.27705344557762146, -0.5027639865875244, 0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Clocking in at an interminable three hours and...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>23</th>\n",
              "      <td>Sudden Impact is the 4th of the Dirty Harry fi...</td>\n",
              "      <td>[-0.5442849397659302, 0.2992677688598633, -0.2...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Sudden Impact is the 4th of the Dirty Harry fi...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24</th>\n",
              "      <td>In a genre by itself, this film has a limited ...</td>\n",
              "      <td>[-0.14087404310703278, 0.12531475722789764, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>In a genre by itself, this film has a limited ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>25</th>\n",
              "      <td>The One and only was a great film. I had just ...</td>\n",
              "      <td>[-0.68660968542099, 0.14108557999134064, 0.091...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>The One and only was a great film. I had just ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>26</th>\n",
              "      <td>If you are 10 years old and never seen a movie...</td>\n",
              "      <td>[-0.6596466302871704, 0.1337697058916092, -0.1...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>If you are 10 years old and never seen a movie...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>27</th>\n",
              "      <td>Even if it were remotely funny, this mouldy wa...</td>\n",
              "      <td>[-0.6116098761558533, 0.49599868059158325, 0.0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Even if it were remotely funny, this mouldy wa...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>28</th>\n",
              "      <td>This is one of the best bond games i have ever...</td>\n",
              "      <td>[-0.03306262567639351, -0.01435087714344263, -...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This is one of the best bond games i have ever...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>29</th>\n",
              "      <td>The performances rate better than the rating I...</td>\n",
              "      <td>[-0.9807755947113037, 0.5014723539352417, -0.4...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>The performances rate better than the rating I...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>30</th>\n",
              "      <td>Chinese Ghost Story III is a totally superfluo...</td>\n",
              "      <td>[0.17701220512390137, -0.3180699050426483, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Chinese Ghost Story III is a totally superfluo...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>31</th>\n",
              "      <td>Fred Williamson, one of the two or three top b...</td>\n",
              "      <td>[-0.3707915246486664, 0.044643059372901917, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Fred Williamson, one of the two or three top b...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>32</th>\n",
              "      <td>Vince Lombardi High School has a new principal...</td>\n",
              "      <td>[-0.49639755487442017, 0.48042890429496765, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Vince Lombardi High School has a new principal...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>33</th>\n",
              "      <td>It's hard to comment on this movie. It's one o...</td>\n",
              "      <td>[-0.3472699224948883, 0.6240038275718689, -0.2...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>It's hard to comment on this movie. It's one o...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>34</th>\n",
              "      <td>I commend pictures that try something differen...</td>\n",
              "      <td>[-0.3393455743789673, 0.5790384411811829, -0.1...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I commend pictures that try something differen...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>35</th>\n",
              "      <td>It's not just that this is a bad movie; it's n...</td>\n",
              "      <td>[-0.3814673125743866, -0.26899996399879456, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>It's not just that this is a bad movie; it's n...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>36</th>\n",
              "      <td>In order to enjoy 'Fur - An imaginary portrait...</td>\n",
              "      <td>[-0.03743020445108414, 0.3995753526687622, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>In order to enjoy 'Fur - An imaginary portrait...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>37</th>\n",
              "      <td>I became a fan of the TV series `Homicide: Lif...</td>\n",
              "      <td>[-0.4682881832122803, -0.018485404551029205, -...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I became a fan of the TV series `Homicide: Lif...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>38</th>\n",
              "      <td>A terminally dull mystery-thriller, which may ...</td>\n",
              "      <td>[-0.18775352835655212, 0.06152409315109253, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>A terminally dull mystery-thriller, which may ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>39</th>\n",
              "      <td>this movie, while it could be considered an al...</td>\n",
              "      <td>[-0.507961094379425, 0.4713260531425476, -0.16...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>this movie, while it could be considered an al...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>40</th>\n",
              "      <td>This is the \"Battlefield Earth\" of mini series...</td>\n",
              "      <td>[-0.4353094696998596, 0.027452869340777397, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This is the \"Battlefield Earth\" of mini series...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>41</th>\n",
              "      <td>DVD has become the equivalent of the old late ...</td>\n",
              "      <td>[-0.1517794281244278, 0.2896312475204468, -0.2...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>DVD has become the equivalent of the old late ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>42</th>\n",
              "      <td>I saw this movie when I was very young living ...</td>\n",
              "      <td>[-0.14374561607837677, 0.10458363592624664, -0...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I saw this movie when I was very young living ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>43</th>\n",
              "      <td>This may not be a memorable classic, but it is...</td>\n",
              "      <td>[-0.6834889650344849, 0.5808060169219971, -0.2...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This may not be a memorable classic, but it is...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>44</th>\n",
              "      <td>This is a great film for pure entertainment, n...</td>\n",
              "      <td>[-0.5870745778083801, 0.007088684476912022, 0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This is a great film for pure entertainment, n...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>45</th>\n",
              "      <td>When I saw this on TV I was nervous...whats if...</td>\n",
              "      <td>[-0.8343449234962463, 0.2768908441066742, -0.5...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>When I saw this on TV I was nervous...whats if...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>46</th>\n",
              "      <td>This film without doubt is one of the worst I ...</td>\n",
              "      <td>[-0.48633041977882385, 0.6339375972747803, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This film without doubt is one of the worst I ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>47</th>\n",
              "      <td>\"Challenge to be Free\" was one of the first fi...</td>\n",
              "      <td>[-0.30197039246559143, 0.4937012493610382, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>\"Challenge to be Free\" was one of the first fi...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>48</th>\n",
              "      <td>I bought this movie a few days ago, and though...</td>\n",
              "      <td>[-0.6582587361335754, 0.1842564195394516, -0.2...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>I bought this movie a few days ago, and though...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>49</th>\n",
              "      <td>This movie is not as good as all think. the ac...</td>\n",
              "      <td>[-0.33901163935661316, 0.04764261469244957, 0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "      <td>This movie is not as good as all think. the ac...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-740b2ac8-3077-4293-8405-e98332304cb9')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-740b2ac8-3077-4293-8405-e98332304cb9 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-740b2ac8-3077-4293-8405-e98332304cb9');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-2234fd71-1bb2-43d0-80ff-bff3c7611ec4\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-2234fd71-1bb2-43d0-80ff-bff3c7611ec4')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-2234fd71-1bb2-43d0-80ff-bff3c7611ec4 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 10
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "lVyOE2wV0fw_"
      },
      "source": [
        "# 4. Test the fitted pipe on new example"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 150
        },
        "id": "qdCUg2MR0PD2",
        "outputId": "b04708fa-2610-4b7d-fe94-3caf9811a6f7"
      },
      "source": [
        "fitted_pipe.predict('It was one of the best films i have ever watched in my entire life !')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "sentence_detector_dl download started this may take some time.\n",
            "Approximate size to download 354.6 KB\n",
            "[OK!]\n",
            "Warning::Spark Session already created, some configs may not take.\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                            sentence  \\\n",
              "0  It was one of the best films i have ever watch...   \n",
              "\n",
              "                sentence_embedding_small_bert_L2_128 sentiment  \\\n",
              "0  [-0.6158236265182495, -0.5645654201507568, -0....  positive   \n",
              "\n",
              "  sentiment_confidence  \n",
              "0             0.997638  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-bfa70970-dfcf-4b69-88b5-21896099f32f\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>sentence</th>\n",
              "      <th>sentence_embedding_small_bert_L2_128</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>It was one of the best films i have ever watch...</td>\n",
              "      <td>[-0.6158236265182495, -0.5645654201507568, -0....</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.997638</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-bfa70970-dfcf-4b69-88b5-21896099f32f')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-bfa70970-dfcf-4b69-88b5-21896099f32f button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-bfa70970-dfcf-4b69-88b5-21896099f32f');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 11
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "xflpwrVjjBVD"
      },
      "source": [
        "## 5. Configure pipe training parameters"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "UtsAUGTmOTms",
        "outputId": "3a0f86bb-f26c-4500-fa1b-1bde63e945df"
      },
      "source": [
        "trainable_pipe.print_info()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",
            ">>> component_list['bert_sentence_embeddings@sent_small_bert_L2_128'] has settable params:\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setBatchSize(8)              | Info: Size of every batch | Currently set to : 8\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setEngine('tensorflow')      | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setIsLong(False)             | Info: Use Long type instead of Int type for inputs buffer - Some Bert models require Long instead of Int. | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setMaxSentenceLength(128)    | Info: Max sentence length to process | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setDimension(128)            | Info: Number of embedding dimensions | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setCaseSensitive(False)      | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n",
            ">>> component_list['document_assembler'] has settable params:\n",
            "component_list['document_assembler'].setCleanupMode('shrink')                                  | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n",
            ">>> component_list['sentiment_dl@sent_small_bert_L2_128'] has settable params:\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setEngine('tensorflow')                  | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setThreshold(0.6)                        | Info: The minimum threshold for the final result otheriwse it will be neutral | Currently set to : 0.6\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setThresholdLabel('neutral')             | Info: In case the score is less than threshold, what should be the label. Default is neutral. | Currently set to : neutral\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "2GJdDNV9jEIe"
      },
      "source": [
        "## 6. Retrain with new parameters"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "mptfvHx-MMMX",
        "outputId": "b48d685f-0ad3-4b22-b79f-a0897eaaf8e2"
      },
      "source": [
        "# Train longer!\n",
        "trainable_pipe = nlp.load('train.sentiment')\n",
        "trainable_pipe['trainable_sentiment_dl'].setMaxEpochs(5)\n",
        "fitted_pipe = trainable_pipe.fit(train_df.iloc[:50])\n",
        "# predict with the trainable pipeline on dataset and get predictions\n",
        "preds = fitted_pipe.predict(train_df.iloc[:50],output_level='document')\n",
        "\n",
        "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))\n",
        "\n",
        "preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "sent_small_bert_L2_128 download started this may take some time.\n",
            "Approximate size to download 16.1 MB\n",
            "[OK!]\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       0.56      1.00      0.72        28\n",
            "    positive       0.00      0.00      0.00        22\n",
            "\n",
            "    accuracy                           0.56        50\n",
            "   macro avg       0.28      0.50      0.36        50\n",
            "weighted avg       0.31      0.56      0.40        50\n",
            "\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                             document  \\\n",
              "0   Set in 1945, Skenbart follows a failed Swedish...   \n",
              "1   I can't believe I watched this whole movie. An...   \n",
              "2   I'm beginning to see a pattern in the movies I...   \n",
              "3   Dan, the widowed father of three girls, has hi...   \n",
              "4   David Webb Peoples meets Paul Anderson...if it...   \n",
              "5   I love MIDNIGHT COWBOY and have it in my video...   \n",
              "6   I have NEVER EVER seen such a bad movie before...   \n",
              "7   I absolutely could not believe the levels of i...   \n",
              "8   A brash, self-centered Army cadet arrives at W...   \n",
              "9   The film is a remake of a 1956 BBC serial call...   \n",
              "10  Though Frank Loesser's songs are some of the f...   \n",
              "11  Rented(free rental thank goodness) this as sup...   \n",
              "12  This is one of those movies that make better t...   \n",
              "13  What can be said of this independent effort be...   \n",
              "14  Wow. I thought this might be insipid but it wa...   \n",
              "15  There is part of one sequence where some water...   \n",
              "16  i got a copy from the writer of this movie on ...   \n",
              "17  ... or was Honest Iago actually smirking at th...   \n",
              "18  First of all, I'd like to say that I love the ...   \n",
              "19  What an embarassment...This doesnt do justice ...   \n",
              "20  One of the worst movies ever made. Let's start...   \n",
              "21  This movie is humorous, charming, and easily b...   \n",
              "22  The movie starts something like a less hyper-k...   \n",
              "23  I won't say this movie was bad, but it wasn't ...   \n",
              "24  Wow! In my opinion, THE NET is an excellent, n...   \n",
              "25  Falsely accused, skirt-chasing chums John Wayn...   \n",
              "26  The Education of Little Tree is just not as go...   \n",
              "27  Interesting film about an actual event that to...   \n",
              "28  I have been a Mario fan for as long as I can r...   \n",
              "29  This woman never stops talking throughout the ...   \n",
              "30  <br /><br />I still can't belive Louis Gossett...   \n",
              "31  Florence Chadwick was actually the far more ac...   \n",
              "32  This may be one of the best movies I have ever...   \n",
              "33  Othello is set to burn the eyes of the viewers...   \n",
              "34  The statistics in this movie were well researc...   \n",
              "35  Following their daughter's brutal murder,Julie...   \n",
              "36  Compelling and Innovative! At the beginning of...   \n",
              "37  I saw this movie when it aired on Lifetime bac...   \n",
              "38  I really wanted to like this movie. I absolute...   \n",
              "39  This comment discusses \"North and South Book I...   \n",
              "40  Rarely have I seen an action/suspense movie th...   \n",
              "41  This is a 100% improvement over the dross of a...   \n",
              "42  I liked it better than House Party 2 & 3. The ...   \n",
              "43  A friend and I went to see this movie. We have...   \n",
              "44  Whattt was with the sound? It sounded like it ...   \n",
              "45  My college theater just had a special screenin...   \n",
              "46  Kingdom County, Vermont, 1927. Noel Lord (Rip ...   \n",
              "47  Man, I really enjoyed this, if only for Fred W...   \n",
              "48  You've seen the same tired, worn out clichéd s...   \n",
              "49  This movie is really genuine and random. It's ...   \n",
              "\n",
              "                 sentence_embedding_small_bert_L2_128 sentiment  \\\n",
              "0   [-0.37176743149757385, 0.28505513072013855, -0...  negative   \n",
              "1   [-0.6678956151008606, 0.4565986394882202, -0.3...  negative   \n",
              "2   [-0.4640607237815857, 0.13232995569705963, -0....  negative   \n",
              "3   [-1.204692006111145, 0.2007242888212204, -0.27...  negative   \n",
              "4   [-0.23281101882457733, 0.1650732308626175, 0.1...  negative   \n",
              "5   [-0.731963574886322, 0.055591657757759094, -0....  negative   \n",
              "6   [-0.8489042520523071, -0.11029214411973953, -0...  negative   \n",
              "7   [-0.7605423331260681, 0.3872695565223694, -0.2...  negative   \n",
              "8   [-0.6972024440765381, 0.3831547200679779, -0.2...  negative   \n",
              "9   [-0.19118931889533997, 0.3001491129398346, 0.0...  negative   \n",
              "10  [-0.5250385999679565, 0.13566239178180695, -0....  negative   \n",
              "11  [-0.83491051197052, 0.5083938837051392, -0.224...  negative   \n",
              "12  [-0.2737158536911011, 0.3766928017139435, -0.2...  negative   \n",
              "13  [-0.18508094549179077, 0.3635772466659546, -0....  negative   \n",
              "14  [-0.4717271327972412, 0.4512611925601959, -0.3...  negative   \n",
              "15  [-0.3119819164276123, 0.24397613108158112, -0....  negative   \n",
              "16  [-0.4513140022754669, 0.25351178646087646, -0....  negative   \n",
              "17  [-0.448510080575943, 0.3488628566265106, 0.424...  negative   \n",
              "18  [-0.7053700685501099, -0.1855289489030838, 0.1...  negative   \n",
              "19  [-0.9799928069114685, 0.37281569838523865, -0....  negative   \n",
              "20  [-0.63435959815979, -0.03198552504181862, -0.3...  negative   \n",
              "21  [-0.5476221442222595, 0.45070168375968933, 0.0...  negative   \n",
              "22  [-0.550375759601593, -0.21221719682216644, -0....  negative   \n",
              "23  [-0.5449793934822083, 0.3829023241996765, -0.2...  negative   \n",
              "24  [-0.9690271615982056, 0.5579360127449036, -0.3...  negative   \n",
              "25  [-0.7523209452629089, 0.8658801913261414, 0.18...  negative   \n",
              "26  [-0.775317370891571, 0.23664450645446777, -0.0...  negative   \n",
              "27  [-0.7987304329872131, 0.3676035404205322, 0.11...  negative   \n",
              "28  [-0.25044935941696167, -0.36489105224609375, -...  negative   \n",
              "29  [-0.7558593153953552, 0.573503315448761, -0.11...  negative   \n",
              "30  [-0.5051725506782532, 0.4716736972332001, 0.07...  negative   \n",
              "31  [-0.8047178387641907, 0.6103856563568115, -0.2...  negative   \n",
              "32  [-0.9392787218093872, -0.002228498924523592, -...  negative   \n",
              "33  [-0.5233349800109863, -0.0218301210552454, 0.0...  negative   \n",
              "34  [-0.4964343309402466, -0.1613437831401825, 0.0...  negative   \n",
              "35  [-0.45342516899108887, 0.025125373154878616, -...  negative   \n",
              "36  [-0.39057832956314087, 0.07514691352844238, 0....  negative   \n",
              "37  [-0.4824381172657013, -0.024186618626117706, -...  negative   \n",
              "38  [-0.5213059782981873, 0.08636035025119781, 0.0...  negative   \n",
              "39  [-1.0346614122390747, 0.5499882698059082, -0.0...  negative   \n",
              "40  [0.08839510381221771, -0.08421049267053604, -0...  negative   \n",
              "41  [-0.4159573018550873, 0.1026173010468483, -0.1...  negative   \n",
              "42  [-0.37537163496017456, 0.2604108452796936, 0.0...  negative   \n",
              "43  [-0.30783846974372864, 0.0511380173265934, -0....  negative   \n",
              "44  [-0.591052234172821, 0.5442489385604858, 0.109...  negative   \n",
              "45  [-0.47453969717025757, 0.33813729882240295, -0...  negative   \n",
              "46  [-0.7206570506095886, 0.63383948802948, -0.231...  negative   \n",
              "47  [-0.9212082624435425, 0.2386074960231781, 0.20...  negative   \n",
              "48  [-0.6829520463943481, 0.18268251419067383, 0.1...  negative   \n",
              "49  [-0.2603294849395752, -0.09567182511091232, -0...  negative   \n",
              "\n",
              "   sentiment_confidence                                               text  \\\n",
              "0                   3.0  Set in 1945, Skenbart follows a failed Swedish...   \n",
              "1                   2.0  I can't believe I watched this whole movie. An...   \n",
              "2                   3.0  I'm beginning to see a pattern in the movies I...   \n",
              "3                   1.0  Dan, the widowed father of three girls, has hi...   \n",
              "4                   2.0  David Webb Peoples meets Paul Anderson...if it...   \n",
              "5                   3.0  I love MIDNIGHT COWBOY and have it in my video...   \n",
              "6                   2.0  I have NEVER EVER seen such a bad movie before...   \n",
              "7                   2.0  I absolutely could not believe the levels of i...   \n",
              "8                   3.0  A brash, self-centered Army cadet arrives at W...   \n",
              "9                   4.0  The film is a remake of a 1956 BBC serial call...   \n",
              "10                  5.0  Though Frank Loesser's songs are some of the f...   \n",
              "11                  3.0  Rented(free rental thank goodness) this as sup...   \n",
              "12                  3.0  This is one of those movies that make better t...   \n",
              "13                  2.0  What can be said of this independent effort be...   \n",
              "14                  1.0  Wow. I thought this might be insipid but it wa...   \n",
              "15                  1.0  There is part of one sequence where some water...   \n",
              "16                  1.0  i got a copy from the writer of this movie on ...   \n",
              "17                  3.0  ... or was Honest Iago actually smirking at th...   \n",
              "18                  3.0  First of all, I'd like to say that I love the ...   \n",
              "19                  1.0  What an embarassment...This doesnt do justice ...   \n",
              "20                  3.0  One of the worst movies ever made. Let's start...   \n",
              "21                  5.0  This movie is humorous, charming, and easily b...   \n",
              "22                  6.0  The movie starts something like a less hyper-k...   \n",
              "23                  2.0  I won't say this movie was bad, but it wasn't ...   \n",
              "24                  5.0  Wow! In my opinion, THE NET is an excellent, n...   \n",
              "25                  6.0  Falsely accused, skirt-chasing chums John Wayn...   \n",
              "26                  3.0  The Education of Little Tree is just not as go...   \n",
              "27                  3.0  Interesting film about an actual event that to...   \n",
              "28                  7.0  I have been a Mario fan for as long as I can r...   \n",
              "29                  1.0  This woman never stops talking throughout the ...   \n",
              "30                  9.0  <br /><br />I still can't belive Louis Gossett...   \n",
              "31                  9.0  Florence Chadwick was actually the far more ac...   \n",
              "32                  3.0  This may be one of the best movies I have ever...   \n",
              "33                  2.0  Othello is set to burn the eyes of the viewers...   \n",
              "34                  2.0  The statistics in this movie were well researc...   \n",
              "35                  6.0  Following their daughter's brutal murder,Julie...   \n",
              "36                  9.0  Compelling and Innovative! At the beginning of...   \n",
              "37                  2.0  I saw this movie when it aired on Lifetime bac...   \n",
              "38                  2.0  I really wanted to like this movie. I absolute...   \n",
              "39                  9.0  This comment discusses \"North and South Book I...   \n",
              "40                  3.0  Rarely have I seen an action/suspense movie th...   \n",
              "41                  2.0  This is a 100% improvement over the dross of a...   \n",
              "42                  3.0  I liked it better than House Party 2 & 3. The ...   \n",
              "43                  4.0  A friend and I went to see this movie. We have...   \n",
              "44                  1.0  Whattt was with the sound? It sounded like it ...   \n",
              "45                  2.0  My college theater just had a special screenin...   \n",
              "46                  1.0  Kingdom County, Vermont, 1927. Noel Lord (Rip ...   \n",
              "47                  3.0  Man, I really enjoyed this, if only for Fred W...   \n",
              "48                  4.0  You've seen the same tired, worn out clichéd s...   \n",
              "49                  2.0  This movie is really genuine and random. It's ...   \n",
              "\n",
              "           y  \n",
              "0   negative  \n",
              "1   negative  \n",
              "2   negative  \n",
              "3   positive  \n",
              "4   positive  \n",
              "5   positive  \n",
              "6   negative  \n",
              "7   negative  \n",
              "8   positive  \n",
              "9   positive  \n",
              "10  negative  \n",
              "11  negative  \n",
              "12  positive  \n",
              "13  negative  \n",
              "14  negative  \n",
              "15  negative  \n",
              "16  negative  \n",
              "17  positive  \n",
              "18  negative  \n",
              "19  negative  \n",
              "20  negative  \n",
              "21  positive  \n",
              "22  positive  \n",
              "23  negative  \n",
              "24  positive  \n",
              "25  negative  \n",
              "26  negative  \n",
              "27  negative  \n",
              "28  positive  \n",
              "29  negative  \n",
              "30  negative  \n",
              "31  negative  \n",
              "32  positive  \n",
              "33  negative  \n",
              "34  negative  \n",
              "35  positive  \n",
              "36  positive  \n",
              "37  positive  \n",
              "38  negative  \n",
              "39  positive  \n",
              "40  negative  \n",
              "41  positive  \n",
              "42  positive  \n",
              "43  negative  \n",
              "44  negative  \n",
              "45  positive  \n",
              "46  positive  \n",
              "47  positive  \n",
              "48  negative  \n",
              "49  positive  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-8e735e00-3e71-42ed-8c9d-c48534852631\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>document</th>\n",
              "      <th>sentence_embedding_small_bert_L2_128</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "      <th>text</th>\n",
              "      <th>y</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Set in 1945, Skenbart follows a failed Swedish...</td>\n",
              "      <td>[-0.37176743149757385, 0.28505513072013855, -0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Set in 1945, Skenbart follows a failed Swedish...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>I can't believe I watched this whole movie. An...</td>\n",
              "      <td>[-0.6678956151008606, 0.4565986394882202, -0.3...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>I can't believe I watched this whole movie. An...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>I'm beginning to see a pattern in the movies I...</td>\n",
              "      <td>[-0.4640607237815857, 0.13232995569705963, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>I'm beginning to see a pattern in the movies I...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>Dan, the widowed father of three girls, has hi...</td>\n",
              "      <td>[-1.204692006111145, 0.2007242888212204, -0.27...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Dan, the widowed father of three girls, has hi...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>David Webb Peoples meets Paul Anderson...if it...</td>\n",
              "      <td>[-0.23281101882457733, 0.1650732308626175, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>David Webb Peoples meets Paul Anderson...if it...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>I love MIDNIGHT COWBOY and have it in my video...</td>\n",
              "      <td>[-0.731963574886322, 0.055591657757759094, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>I love MIDNIGHT COWBOY and have it in my video...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>I have NEVER EVER seen such a bad movie before...</td>\n",
              "      <td>[-0.8489042520523071, -0.11029214411973953, -0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>I have NEVER EVER seen such a bad movie before...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>I absolutely could not believe the levels of i...</td>\n",
              "      <td>[-0.7605423331260681, 0.3872695565223694, -0.2...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>I absolutely could not believe the levels of i...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>A brash, self-centered Army cadet arrives at W...</td>\n",
              "      <td>[-0.6972024440765381, 0.3831547200679779, -0.2...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>A brash, self-centered Army cadet arrives at W...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>The film is a remake of a 1956 BBC serial call...</td>\n",
              "      <td>[-0.19118931889533997, 0.3001491129398346, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>The film is a remake of a 1956 BBC serial call...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>10</th>\n",
              "      <td>Though Frank Loesser's songs are some of the f...</td>\n",
              "      <td>[-0.5250385999679565, 0.13566239178180695, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>Though Frank Loesser's songs are some of the f...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>11</th>\n",
              "      <td>Rented(free rental thank goodness) this as sup...</td>\n",
              "      <td>[-0.83491051197052, 0.5083938837051392, -0.224...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Rented(free rental thank goodness) this as sup...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12</th>\n",
              "      <td>This is one of those movies that make better t...</td>\n",
              "      <td>[-0.2737158536911011, 0.3766928017139435, -0.2...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>This is one of those movies that make better t...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>13</th>\n",
              "      <td>What can be said of this independent effort be...</td>\n",
              "      <td>[-0.18508094549179077, 0.3635772466659546, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>What can be said of this independent effort be...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>14</th>\n",
              "      <td>Wow. I thought this might be insipid but it wa...</td>\n",
              "      <td>[-0.4717271327972412, 0.4512611925601959, -0.3...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Wow. I thought this might be insipid but it wa...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>15</th>\n",
              "      <td>There is part of one sequence where some water...</td>\n",
              "      <td>[-0.3119819164276123, 0.24397613108158112, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>There is part of one sequence where some water...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>16</th>\n",
              "      <td>i got a copy from the writer of this movie on ...</td>\n",
              "      <td>[-0.4513140022754669, 0.25351178646087646, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>i got a copy from the writer of this movie on ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>17</th>\n",
              "      <td>... or was Honest Iago actually smirking at th...</td>\n",
              "      <td>[-0.448510080575943, 0.3488628566265106, 0.424...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>... or was Honest Iago actually smirking at th...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>18</th>\n",
              "      <td>First of all, I'd like to say that I love the ...</td>\n",
              "      <td>[-0.7053700685501099, -0.1855289489030838, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>First of all, I'd like to say that I love the ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>19</th>\n",
              "      <td>What an embarassment...This doesnt do justice ...</td>\n",
              "      <td>[-0.9799928069114685, 0.37281569838523865, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>What an embarassment...This doesnt do justice ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>20</th>\n",
              "      <td>One of the worst movies ever made. Let's start...</td>\n",
              "      <td>[-0.63435959815979, -0.03198552504181862, -0.3...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>One of the worst movies ever made. Let's start...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>21</th>\n",
              "      <td>This movie is humorous, charming, and easily b...</td>\n",
              "      <td>[-0.5476221442222595, 0.45070168375968933, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>This movie is humorous, charming, and easily b...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>22</th>\n",
              "      <td>The movie starts something like a less hyper-k...</td>\n",
              "      <td>[-0.550375759601593, -0.21221719682216644, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>The movie starts something like a less hyper-k...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>23</th>\n",
              "      <td>I won't say this movie was bad, but it wasn't ...</td>\n",
              "      <td>[-0.5449793934822083, 0.3829023241996765, -0.2...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>I won't say this movie was bad, but it wasn't ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24</th>\n",
              "      <td>Wow! In my opinion, THE NET is an excellent, n...</td>\n",
              "      <td>[-0.9690271615982056, 0.5579360127449036, -0.3...</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>Wow! In my opinion, THE NET is an excellent, n...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>25</th>\n",
              "      <td>Falsely accused, skirt-chasing chums John Wayn...</td>\n",
              "      <td>[-0.7523209452629089, 0.8658801913261414, 0.18...</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>Falsely accused, skirt-chasing chums John Wayn...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>26</th>\n",
              "      <td>The Education of Little Tree is just not as go...</td>\n",
              "      <td>[-0.775317370891571, 0.23664450645446777, -0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>The Education of Little Tree is just not as go...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>27</th>\n",
              "      <td>Interesting film about an actual event that to...</td>\n",
              "      <td>[-0.7987304329872131, 0.3676035404205322, 0.11...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Interesting film about an actual event that to...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>28</th>\n",
              "      <td>I have been a Mario fan for as long as I can r...</td>\n",
              "      <td>[-0.25044935941696167, -0.36489105224609375, -...</td>\n",
              "      <td>negative</td>\n",
              "      <td>7.0</td>\n",
              "      <td>I have been a Mario fan for as long as I can r...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>29</th>\n",
              "      <td>This woman never stops talking throughout the ...</td>\n",
              "      <td>[-0.7558593153953552, 0.573503315448761, -0.11...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>This woman never stops talking throughout the ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>30</th>\n",
              "      <td>&lt;br /&gt;&lt;br /&gt;I still can't belive Louis Gossett...</td>\n",
              "      <td>[-0.5051725506782532, 0.4716736972332001, 0.07...</td>\n",
              "      <td>negative</td>\n",
              "      <td>9.0</td>\n",
              "      <td>&lt;br /&gt;&lt;br /&gt;I still can't belive Louis Gossett...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>31</th>\n",
              "      <td>Florence Chadwick was actually the far more ac...</td>\n",
              "      <td>[-0.8047178387641907, 0.6103856563568115, -0.2...</td>\n",
              "      <td>negative</td>\n",
              "      <td>9.0</td>\n",
              "      <td>Florence Chadwick was actually the far more ac...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>32</th>\n",
              "      <td>This may be one of the best movies I have ever...</td>\n",
              "      <td>[-0.9392787218093872, -0.002228498924523592, -...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>This may be one of the best movies I have ever...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>33</th>\n",
              "      <td>Othello is set to burn the eyes of the viewers...</td>\n",
              "      <td>[-0.5233349800109863, -0.0218301210552454, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>Othello is set to burn the eyes of the viewers...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>34</th>\n",
              "      <td>The statistics in this movie were well researc...</td>\n",
              "      <td>[-0.4964343309402466, -0.1613437831401825, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>The statistics in this movie were well researc...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>35</th>\n",
              "      <td>Following their daughter's brutal murder,Julie...</td>\n",
              "      <td>[-0.45342516899108887, 0.025125373154878616, -...</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>Following their daughter's brutal murder,Julie...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>36</th>\n",
              "      <td>Compelling and Innovative! At the beginning of...</td>\n",
              "      <td>[-0.39057832956314087, 0.07514691352844238, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>9.0</td>\n",
              "      <td>Compelling and Innovative! At the beginning of...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>37</th>\n",
              "      <td>I saw this movie when it aired on Lifetime bac...</td>\n",
              "      <td>[-0.4824381172657013, -0.024186618626117706, -...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>I saw this movie when it aired on Lifetime bac...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>38</th>\n",
              "      <td>I really wanted to like this movie. I absolute...</td>\n",
              "      <td>[-0.5213059782981873, 0.08636035025119781, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>I really wanted to like this movie. I absolute...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>39</th>\n",
              "      <td>This comment discusses \"North and South Book I...</td>\n",
              "      <td>[-1.0346614122390747, 0.5499882698059082, -0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>9.0</td>\n",
              "      <td>This comment discusses \"North and South Book I...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>40</th>\n",
              "      <td>Rarely have I seen an action/suspense movie th...</td>\n",
              "      <td>[0.08839510381221771, -0.08421049267053604, -0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Rarely have I seen an action/suspense movie th...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>41</th>\n",
              "      <td>This is a 100% improvement over the dross of a...</td>\n",
              "      <td>[-0.4159573018550873, 0.1026173010468483, -0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>This is a 100% improvement over the dross of a...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>42</th>\n",
              "      <td>I liked it better than House Party 2 &amp; 3. The ...</td>\n",
              "      <td>[-0.37537163496017456, 0.2604108452796936, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>I liked it better than House Party 2 &amp; 3. The ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>43</th>\n",
              "      <td>A friend and I went to see this movie. We have...</td>\n",
              "      <td>[-0.30783846974372864, 0.0511380173265934, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>A friend and I went to see this movie. We have...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>44</th>\n",
              "      <td>Whattt was with the sound? It sounded like it ...</td>\n",
              "      <td>[-0.591052234172821, 0.5442489385604858, 0.109...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Whattt was with the sound? It sounded like it ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>45</th>\n",
              "      <td>My college theater just had a special screenin...</td>\n",
              "      <td>[-0.47453969717025757, 0.33813729882240295, -0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>My college theater just had a special screenin...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>46</th>\n",
              "      <td>Kingdom County, Vermont, 1927. Noel Lord (Rip ...</td>\n",
              "      <td>[-0.7206570506095886, 0.63383948802948, -0.231...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Kingdom County, Vermont, 1927. Noel Lord (Rip ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>47</th>\n",
              "      <td>Man, I really enjoyed this, if only for Fred W...</td>\n",
              "      <td>[-0.9212082624435425, 0.2386074960231781, 0.20...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Man, I really enjoyed this, if only for Fred W...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>48</th>\n",
              "      <td>You've seen the same tired, worn out clichéd s...</td>\n",
              "      <td>[-0.6829520463943481, 0.18268251419067383, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>You've seen the same tired, worn out clichéd s...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>49</th>\n",
              "      <td>This movie is really genuine and random. It's ...</td>\n",
              "      <td>[-0.2603294849395752, -0.09567182511091232, -0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>This movie is really genuine and random. It's ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-8e735e00-3e71-42ed-8c9d-c48534852631')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-8e735e00-3e71-42ed-8c9d-c48534852631 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-8e735e00-3e71-42ed-8c9d-c48534852631');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-9430208d-7cd1-4ec1-90d4-b51cae1c7cb4\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-9430208d-7cd1-4ec1-90d4-b51cae1c7cb4')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-9430208d-7cd1-4ec1-90d4-b51cae1c7cb4 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 34
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qFoT-s1MjTSS"
      },
      "source": [
        "# 7. Try training with different Embeddings"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "nxWFzQOhjWC8",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "d940310d-dfc6-45ae-c5dc-50d0141c836f"
      },
      "source": [
        "# We can use nlu.print_components(action='embed_sentence') to see every possibler sentence embedding we could use. Lets use bert!\n",
        "nlp.nlu.print_components(action='embed_sentence')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "For language <am> NLU provides the following Models : \n",
            "nlu.load('am.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_amharic\n",
            "For language <de> NLU provides the following Models : \n",
            "nlu.load('de.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "For language <el> NLU provides the following Models : \n",
            "nlu.load('el.embed_sentence.bert.base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "For language <en> NLU provides the following Models : \n",
            "nlu.load('en.embed_sentence') returns Spark NLP model_anno_obj tfhub_use\n",
            "nlu.load('en.embed_sentence.albert') returns Spark NLP model_anno_obj albert_base_uncased\n",
            "nlu.load('en.embed_sentence.bert') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "nlu.load('en.embed_sentence.bert.base_uncased_legal') returns Spark NLP model_anno_obj sent_bert_base_uncased_legal\n",
            "nlu.load('en.embed_sentence.bert.finetuned') returns Spark NLP model_anno_obj sbert_setfit_finetuned_financial_text_classification\n",
            "nlu.load('en.embed_sentence.bert.pubmed') returns Spark NLP model_anno_obj sent_bert_pubmed\n",
            "nlu.load('en.embed_sentence.bert.pubmed_squad2') returns Spark NLP model_anno_obj sent_bert_pubmed_squad2\n",
            "nlu.load('en.embed_sentence.bert.wiki_books') returns Spark NLP model_anno_obj sent_bert_wiki_books\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_mnli') returns Spark NLP model_anno_obj sent_bert_wiki_books_mnli\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_qnli') returns Spark NLP model_anno_obj sent_bert_wiki_books_qnli\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_qqp') returns Spark NLP model_anno_obj sent_bert_wiki_books_qqp\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_squad2') returns Spark NLP model_anno_obj sent_bert_wiki_books_squad2\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_sst2') returns Spark NLP model_anno_obj sent_bert_wiki_books_sst2\n",
            "nlu.load('en.embed_sentence.bert_base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "nlu.load('en.embed_sentence.bert_base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "nlu.load('en.embed_sentence.bert_large_cased') returns Spark NLP model_anno_obj sent_bert_large_cased\n",
            "nlu.load('en.embed_sentence.bert_large_uncased') returns Spark NLP model_anno_obj sent_bert_large_uncased\n",
            "nlu.load('en.embed_sentence.bert_use_cmlm_en_base') returns Spark NLP model_anno_obj sent_bert_use_cmlm_en_base\n",
            "nlu.load('en.embed_sentence.bert_use_cmlm_en_large') returns Spark NLP model_anno_obj sent_bert_use_cmlm_en_large\n",
            "nlu.load('en.embed_sentence.biobert.clinical_base_cased') returns Spark NLP model_anno_obj sent_biobert_clinical_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.discharge_base_cased') returns Spark NLP model_anno_obj sent_biobert_discharge_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.pmc_base_cased') returns Spark NLP model_anno_obj sent_biobert_pmc_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.pubmed_base_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.pubmed_large_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_large_cased\n",
            "nlu.load('en.embed_sentence.biobert.pubmed_pmc_base_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_pmc_base_cased\n",
            "nlu.load('en.embed_sentence.covidbert.large_uncased') returns Spark NLP model_anno_obj sent_covidbert_large_uncased\n",
            "nlu.load('en.embed_sentence.distil_roberta.distilled_base') returns Spark NLP model_anno_obj sent_distilroberta_base\n",
            "nlu.load('en.embed_sentence.doc2vec') returns Spark NLP model_anno_obj doc2vec_gigaword_300\n",
            "nlu.load('en.embed_sentence.doc2vec.gigaword_300') returns Spark NLP model_anno_obj doc2vec_gigaword_300\n",
            "nlu.load('en.embed_sentence.doc2vec.gigaword_wiki_300') returns Spark NLP model_anno_obj doc2vec_gigaword_wiki_300\n",
            "nlu.load('en.embed_sentence.electra') returns Spark NLP model_anno_obj sent_electra_small_uncased\n",
            "nlu.load('en.embed_sentence.electra_base_uncased') returns Spark NLP model_anno_obj sent_electra_base_uncased\n",
            "nlu.load('en.embed_sentence.electra_large_uncased') returns Spark NLP model_anno_obj sent_electra_large_uncased\n",
            "nlu.load('en.embed_sentence.electra_small_uncased') returns Spark NLP model_anno_obj sent_electra_small_uncased\n",
            "nlu.load('en.embed_sentence.roberta.base') returns Spark NLP model_anno_obj sent_roberta_base\n",
            "nlu.load('en.embed_sentence.roberta.large') returns Spark NLP model_anno_obj sent_roberta_large\n",
            "nlu.load('en.embed_sentence.small_bert_L10_128') returns Spark NLP model_anno_obj sent_small_bert_L10_128\n",
            "nlu.load('en.embed_sentence.small_bert_L10_256') returns Spark NLP model_anno_obj sent_small_bert_L10_256\n",
            "nlu.load('en.embed_sentence.small_bert_L10_512') returns Spark NLP model_anno_obj sent_small_bert_L10_512\n",
            "nlu.load('en.embed_sentence.small_bert_L10_768') returns Spark NLP model_anno_obj sent_small_bert_L10_768\n",
            "nlu.load('en.embed_sentence.small_bert_L12_128') returns Spark NLP model_anno_obj sent_small_bert_L12_128\n",
            "nlu.load('en.embed_sentence.small_bert_L12_256') returns Spark NLP model_anno_obj sent_small_bert_L12_256\n",
            "nlu.load('en.embed_sentence.small_bert_L12_512') returns Spark NLP model_anno_obj sent_small_bert_L12_512\n",
            "nlu.load('en.embed_sentence.small_bert_L12_768') returns Spark NLP model_anno_obj sent_small_bert_L12_768\n",
            "nlu.load('en.embed_sentence.small_bert_L2_128') returns Spark NLP model_anno_obj sent_small_bert_L2_128\n",
            "nlu.load('en.embed_sentence.small_bert_L2_256') returns Spark NLP model_anno_obj sent_small_bert_L2_256\n",
            "nlu.load('en.embed_sentence.small_bert_L2_512') returns Spark NLP model_anno_obj sent_small_bert_L2_512\n",
            "nlu.load('en.embed_sentence.small_bert_L2_768') returns Spark NLP model_anno_obj sent_small_bert_L2_768\n",
            "nlu.load('en.embed_sentence.small_bert_L4_128') returns Spark NLP model_anno_obj sent_small_bert_L4_128\n",
            "nlu.load('en.embed_sentence.small_bert_L4_256') returns Spark NLP model_anno_obj sent_small_bert_L4_256\n",
            "nlu.load('en.embed_sentence.small_bert_L4_512') returns Spark NLP model_anno_obj sent_small_bert_L4_512\n",
            "nlu.load('en.embed_sentence.small_bert_L4_768') returns Spark NLP model_anno_obj sent_small_bert_L4_768\n",
            "nlu.load('en.embed_sentence.small_bert_L6_128') returns Spark NLP model_anno_obj sent_small_bert_L6_128\n",
            "nlu.load('en.embed_sentence.small_bert_L6_256') returns Spark NLP model_anno_obj sent_small_bert_L6_256\n",
            "nlu.load('en.embed_sentence.small_bert_L6_512') returns Spark NLP model_anno_obj sent_small_bert_L6_512\n",
            "nlu.load('en.embed_sentence.small_bert_L6_768') returns Spark NLP model_anno_obj sent_small_bert_L6_768\n",
            "nlu.load('en.embed_sentence.small_bert_L8_128') returns Spark NLP model_anno_obj sent_small_bert_L8_128\n",
            "nlu.load('en.embed_sentence.small_bert_L8_256') returns Spark NLP model_anno_obj sent_small_bert_L8_256\n",
            "nlu.load('en.embed_sentence.small_bert_L8_512') returns Spark NLP model_anno_obj sent_small_bert_L8_512\n",
            "nlu.load('en.embed_sentence.small_bert_L8_768') returns Spark NLP model_anno_obj sent_small_bert_L8_768\n",
            "nlu.load('en.embed_sentence.tfhub_use') returns Spark NLP model_anno_obj tfhub_use\n",
            "nlu.load('en.embed_sentence.tfhub_use.lg') returns Spark NLP model_anno_obj tfhub_use_lg\n",
            "nlu.load('en.embed_sentence.use') returns Spark NLP model_anno_obj tfhub_use\n",
            "nlu.load('en.embed_sentence.use.lg') returns Spark NLP model_anno_obj tfhub_use_lg\n",
            "For language <es> NLU provides the following Models : \n",
            "nlu.load('es.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "nlu.load('es.embed_sentence.bert.base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "For language <fi> NLU provides the following Models : \n",
            "nlu.load('fi.embed_sentence.bert') returns Spark NLP model_anno_obj bert_base_finnish_uncased\n",
            "nlu.load('fi.embed_sentence.bert.cased') returns Spark NLP model_anno_obj bert_base_finnish_cased\n",
            "nlu.load('fi.embed_sentence.bert.uncased') returns Spark NLP model_anno_obj bert_base_finnish_uncased\n",
            "For language <ha> NLU provides the following Models : \n",
            "nlu.load('ha.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_hausa\n",
            "For language <ig> NLU provides the following Models : \n",
            "nlu.load('ig.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_igbo\n",
            "For language <lg> NLU provides the following Models : \n",
            "nlu.load('lg.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_luganda\n",
            "For language <nl> NLU provides the following Models : \n",
            "nlu.load('nl.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "For language <pcm> NLU provides the following Models : \n",
            "nlu.load('pcm.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_naija\n",
            "For language <pt> NLU provides the following Models : \n",
            "nlu.load('pt.embed_sentence.bert.base_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_base_tsdae_sts\n",
            "nlu.load('pt.embed_sentence.bert.cased_large_legal') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.1\n",
            "nlu.load('pt.embed_sentence.bert.large_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_gpl_sts\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.10.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.10\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.2.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.2\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.3.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.3\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.4.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.4\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.5.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.5\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.7.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.7\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.8.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.8\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.9.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.9\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v1.0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v1.0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_gpl_nli_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_gpl_nli_sts_v0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_gpl_nli_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_gpl_nli_sts_v1\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_nli_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_nli_sts_v0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_nli_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_nli_sts_v1\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_sts_v0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_sts_v1\n",
            "nlu.load('pt.embed_sentence.bert.v2_base_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base_ma_v2\n",
            "nlu.load('pt.embed_sentence.bert.v2_large_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts_v2\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.assin.base.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base_ma\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.assin2.base.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_ma.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_ma\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_ma_v3.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_ma_v3\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_sts_v4.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts_v4\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_v4_gpl_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_v4_gpl_sts\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.v2_large_sts_v2.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_v2\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.v2_large_v2_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_v2_sts\n",
            "For language <rw> NLU provides the following Models : \n",
            "nlu.load('rw.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_kinyarwanda\n",
            "For language <sv> NLU provides the following Models : \n",
            "nlu.load('sv.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "For language <sw> NLU provides the following Models : \n",
            "nlu.load('sw.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_swahili\n",
            "For language <wo> NLU provides the following Models : \n",
            "nlu.load('wo.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_wolof\n",
            "For language <xx> NLU provides the following Models : \n",
            "nlu.load('xx.embed_sentence') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
            "nlu.load('xx.embed_sentence.bert') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
            "nlu.load('xx.embed_sentence.bert.cased') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
            "nlu.load('xx.embed_sentence.bert.muril') returns Spark NLP model_anno_obj sent_bert_muril\n",
            "nlu.load('xx.embed_sentence.bert_use_cmlm_multi_base') returns Spark NLP model_anno_obj sent_bert_use_cmlm_multi_base\n",
            "nlu.load('xx.embed_sentence.bert_use_cmlm_multi_base_br') returns Spark NLP model_anno_obj sent_bert_use_cmlm_multi_base_br\n",
            "nlu.load('xx.embed_sentence.labse') returns Spark NLP model_anno_obj labse\n",
            "nlu.load('xx.embed_sentence.xlm_roberta.base') returns Spark NLP model_anno_obj sent_xlm_roberta_base\n",
            "For language <yo> NLU provides the following Models : \n",
            "nlu.load('yo.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_yoruba\n",
            "For language <zh> NLU provides the following Models : \n",
            "nlu.load('zh.embed_sentence.bert') returns Spark NLP model_anno_obj sbert_chinese_qmc_finance_v1\n",
            "nlu.load('zh.embed_sentence.bert.distilled') returns Spark NLP model_anno_obj sbert_chinese_qmc_finance_v1_distill\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "IKK_Ii_gjJfF",
        "outputId": "53181dbd-eea1-4b84-ead4-ea49a27d903d"
      },
      "source": [
        "trainable_pipe = nlp.load('en.embed_sentence.small_bert_L12_768 train.sentiment')\n",
        "# We need to train longer and user smaller LR for NON-USE based sentence embeddings usually\n",
        "# We could tune the hyperparameters further with hyperparameter tuning methods like gridsearch\n",
        "# Also longer training gives more accuracy\n",
        "trainable_pipe['trainable_sentiment_dl'].setMaxEpochs(120)\n",
        "trainable_pipe['trainable_sentiment_dl'].setLr(0.0005)\n",
        "fitted_pipe = trainable_pipe.fit(train_df[:100])\n",
        "# predict with the trainable pipeline on dataset and get predictions\n",
        "preds = fitted_pipe.predict(train_df[:100],output_level='document')\n",
        "\n",
        "#sentence detector that is part of the pipe generates some NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))\n",
        "\n",
        "#preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       1.00      0.55      0.71        44\n",
            "     neutral       0.00      0.00      0.00         0\n",
            "    positive       0.98      0.88      0.92        56\n",
            "\n",
            "    accuracy                           0.73       100\n",
            "   macro avg       0.66      0.47      0.54       100\n",
            "weighted avg       0.99      0.73      0.83       100\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "_1jxw3GnVGlI"
      },
      "source": [
        "# 7.1 evaluate on Test Data"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Fxx4yNkNVGFl",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "b9ff1dc4-a29d-4975-9167-0304dfe71278"
      },
      "source": [
        "preds = fitted_pipe.predict(test_df[:100],output_level='document')\n",
        "\n",
        "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       0.94      0.34      0.50        50\n",
            "     neutral       0.00      0.00      0.00         0\n",
            "    positive       0.76      0.64      0.70        50\n",
            "\n",
            "    accuracy                           0.49       100\n",
            "   macro avg       0.57      0.33      0.40       100\n",
            "weighted avg       0.85      0.49      0.60       100\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "2BB-NwZUoHSe"
      },
      "source": [
        "# 8. Lets save the model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eLex095goHwm"
      },
      "source": [
        "stored_model_path = './models/classifier_dl_trained'\n",
        "fitted_pipe.save(stored_model_path)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "e_b2DPd4rCiU"
      },
      "source": [
        "# 9. Lets load the model from HDD.\n",
        "This makes Offlien NLU usage possible!   \n",
        "You need to call nlu.load(path=path_to_the_pipe) to load a model/pipeline from disk."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 133
        },
        "id": "SO4uz45MoRgp",
        "outputId": "a1c68191-a229-4990-e847-a8e9e18d4618"
      },
      "source": [
        "hdd_pipe = nlp.load(path=stored_model_path)\n",
        "\n",
        "preds = hdd_pipe.predict('It was one of the best films i have ever watched in my entire life !!')\n",
        "preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                            document  \\\n",
              "0  It was one of the best films i have ever watch...   \n",
              "\n",
              "                        sentence_embedding_from_disk sentiment  \\\n",
              "0  [0.09222032874822617, 0.1172066256403923, 0.19...  positive   \n",
              "\n",
              "  sentiment_confidence  \n",
              "0                  0.0  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-54c4db12-5b2a-482e-9114-6f74ab673b1e\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>document</th>\n",
              "      <th>sentence_embedding_from_disk</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>It was one of the best films i have ever watch...</td>\n",
              "      <td>[0.09222032874822617, 0.1172066256403923, 0.19...</td>\n",
              "      <td>positive</td>\n",
              "      <td>0.0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-54c4db12-5b2a-482e-9114-6f74ab673b1e')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-54c4db12-5b2a-482e-9114-6f74ab673b1e button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-54c4db12-5b2a-482e-9114-6f74ab673b1e');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "e0CVlkk9v6Qi",
        "outputId": "651f1a33-cb6b-413e-db68-6e11338b3077"
      },
      "source": [
        "hdd_pipe.print_info()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",
            ">>> component_list['document_assembler'] has settable params:\n",
            "component_list['document_assembler'].setCleanupMode('shrink')                                    | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n",
            ">>> component_list['bert_sentence_embeddings@sent_small_bert_L12_768'] has settable params:\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setBatchSize(8)               | Info: Size of every batch | Currently set to : 8\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setCaseSensitive(False)       | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setDimension(768)             | Info: Number of embedding dimensions | Currently set to : 768\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setMaxSentenceLength(128)     | Info: Max sentence length to process | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setEngine('tensorflow')       | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setIsLong(False)              | Info: Use Long type instead of Int type for inputs buffer - Some Bert models require Long instead of Int. | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setStorageRef('sent_small_bert_L12_768')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L12_768\n",
            ">>> component_list['sentiment_dl@sent_small_bert_L12_768'] has settable params:\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setThreshold(0.6)                         | Info: The minimum threshold for the final result otheriwse it will be neutral | Currently set to : 0.6\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setThresholdLabel('neutral')              | Info: In case the score is less than threshold, what should be the label. Default is neutral. | Currently set to : neutral\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setEngine('tensorflow')                   | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setClasses(['positive', 'negative'])      | Info: get the tags used to trained this SentimentDLModel | Currently set to : ['positive', 'negative']\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setStorageRef('sent_small_bert_L12_768')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L12_768\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mtDcALorKHIx"
      },
      "source": [],
      "execution_count": null,
      "outputs": []
    }
  ]
}